#include <iostream>
using namespace std;

int AddDays(int year, int month, int day)
{
    int mondays[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    //判断润年
    if(year%4 == 0 && year%100 != 0 || year%400 == 0)
        mondays[2] += 1;  //二月为闰月 29天
    int ret = 0;
    for(int i = 0; i < month; ++i){
        ret += mondays[i];
    }
    ret += day;
    return ret;
}

int main()
{
    int years, months, days;
    cin >> years >> months >> days;
    
    cout << AddDays(years, months, days);
    return 0;
}